﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed
#pragma once

#include "ICommandControlDefinition.h"
#include "GcmpApiDeclaration.h"

namespace gcmp
{
    class IMenuItemDefinition;

    /// \brief CommandButtonMenu控件数据定义接口
    class GCMP_GUI_BASE_INTERFACE_EXPORT ICommandButtonMenuDefinition : public ICommandControlDefinition
    {
    public:

        /// \brief 创建ICommandButtonMenuDefinition对象
        ///
        /// \param id       CommandButtonMenu控件数据定义的id,需保证唯一性
        /// \param commandId  命令的id
        /// \param caption    控件标题
        /// \param iconPath   图标路径
        /// \param tooltip    控件的提示信息
        /// \return  创建出ICommandButtonMenuDefinition对象。失败时返回空
        static OwnerPtr<ICommandButtonMenuDefinition> Create(const std::wstring& id, const std::wstring& commandId, const std::wstring& caption, const std::wstring& iconPath, const std::wstring& tooltip = L"");

        /// \brief 创建pCommandButtonMenuDefinition的引用对象
        ///
        /// 不能通过引用创建引用；pCommandButtonMenuDefinition需加到IControlDefinitionLibrary后才能创建引用对象
        /// \param pCommandButtonMenuDefinition 被引用的ICommandButtonMenuDefinition对象
        /// \return pCommandButtonMenuDefinition的引用对象
        static OwnerPtr<ICommandButtonMenuDefinition> CreateReference(const ICommandButtonMenuDefinition* pCommandButtonMenuDefinition);

        /// \brief 添加item至最后
        ///
        /// \param pMenuItemDefinition    IMenuItemDefinition对象
        /// \return   true表示成功，如果ICommandButtonMenuDefinition已包含pMenuItemDefinition对象,则返回false 
        virtual bool AddItem(OwnerPtr<IMenuItemDefinition> pMenuItemDefinition) = 0;

        /// \brief 插入Item
        ///
        /// 如果ICommandButtonMenuDefinition,则返回失败
        /// \param beforeId  被插入对象的id
        /// \param pMenuItemDefinition    IMenuItemDefinition对象        
        /// \return     true表示成功， 如果ICommandButtonMenuDefinition不包含Id为beforeId的IMenuItemDefinition或包含pMenuItemDefinition对象，则返回false
        virtual bool InsertItem(const std::wstring& beforeId, OwnerPtr<IMenuItemDefinition> pMenuItemDefinition) = 0;

        /// \brief 删除所有Item
        virtual void DeleteAllItems() = 0;
 
        /// \brief 得到IMenuItemDefinition对象
        ///
        /// \param id   IMenuItemDefinition的id
        /// \return  IMenuItemDefinition对象，如果ICommandButtonMenuDefinition不包含Id为id的IMenuItemDefinition,则返回空指针
        virtual IMenuItemDefinition* GetItem(const std::wstring& id) const = 0;

        /// \brief 得到所有的item
        ///
        /// \return  IMenuItemDefinition集合
        virtual std::vector<IMenuItemDefinition*> GetAllItems() const = 0;
        
        /// \brief 得到图标路径
        virtual std::wstring GetIconPath() const = 0;

        /// \brief 设置ButtonMenu上显示的文字
        ///
        /// \param caption 待设置的文字说明
        /// \return true设置成功， false设置失败
        virtual bool SetCaption(const std::wstring& caption) = 0;

        /// \brief 设置ButtonMenu上显示的图标
        ///
        /// \param iconPath 待设置的图标路径
        /// \return true表示设置成功， false表示设置失败
        virtual bool SetIconPath(const std::wstring& iconPath) = 0;

        /// \brief 设置ButtonMenu上显示的提示信息
        ///
        /// \param tooltip 待设置的提示信息
        /// \return true表示设置成功， false表示设置失败
        virtual bool SetTooltip(const std::wstring& tooltip) = 0;

        /// \brief 是否自动修改ButtonMenu的显示信息
        ///
        /// 显示信息主要包括图标、标题及提示信息。当用户选中某子菜单时，子菜单的图标、标题、提示信息显示到该菜单上
        /// \return true表示需要修改对应信息， false表示不修改对应信息
        virtual bool IsAutoChangeDisplayInformation() const = 0;

        /// \brief 设置ButtonMenu是否自动修改显示信息
        ///
        /// 请参考IsAutoChangeDisplayInformation()中显示信息的定义
        /// \param isAutoChangeDisplayInformation true表示设置需要修改显示信息，false表示不修改信息
        /// \return true表示设置成功， false表示设置失败
        virtual bool SetAutoChangeDisplayInformation(bool isAutoChangeDisplayInformation) = 0;
    };
}
